<?php
/**
 * Created by JetBrains PhpStorm.
 * User: zhouyang
 * Date: 13-7-15
 * Time: 下午4:31
 * To change this template use File | Settings | File Templates.
 */
class CategoryHasTagsModel  extends Model{

    //检查信息是否已经添加
    public function getCategoryHasTags($category_id,$tag_id){
        $row = $this->dbreader()->getCategoryHasTags($category_id,$tag_id);
        return $row;
    }

    //添加 category 拥有的 tag 信息
    public function addCategoryHasTags($category_id,$tag_id){
        $ret = $this->getCategoryHasTags($category_id,$tag_id);

        if(empty($ret)){
            $ret = $this->dbreader()->addCategoryHasTags($category_id,$tag_id);
        }
        return $ret;
    }

    //删除 tag_id 对应的信息
    public function delByTagId($tag_id){
        $ret = $this->dbreader()->delByTagId($tag_id);
        return $ret;
    }

    //删除 category_id 对应的信息
    public function delByCategoryId($category_id){
        $ret = $this->dbreader()->delByCategoryId($category_id);
        return $ret;
    }

    //删除 category_id and tag_id 对应的信息
    public function delByCategoryIdAndTagID($category_id,$tag_id){
        $ret = $this->dbreader()->delByCategoryIdAndTagID($category_id,$tag_id);
        return $ret;
    }

    //修改当前新闻标签所属类型
    public function updateCategoryHasTags($category_id,$old_category_id,$tag_id){
        $ret = $this->dbreader()->updateCategoryHasTags($category_id,$old_category_id,$tag_id);
        return $ret;
    }
}